package com.yonder.gocommand.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yonder.gocommand.dao.IUserDAO;
import com.yonder.gocommand.entity.User;
import com.yonder.gocommand.service.IUserService;

@Service("UserService")
@Transactional
public class UserServiceImpl implements IUserService {

	private static final Logger LOGGER = LoggerFactory.getLogger(IUserService.class);
	private Date currentDateTime = new Date();
	private SimpleDateFormat sdf = new SimpleDateFormat("HH:mm dd/MM/yyyy");
	
	
	@Autowired
	private IUserDAO userDAO;

	@Override
	public void saveOrUpdate(User u) {
		LOGGER.info("saveOrUpdate: " + u.getUsername() + " " + sdf.format(currentDateTime));
		userDAO.saveOrUpdate(u);
	}

	@Override
	public User existUser(String u) {
		LOGGER.info("existUser" + " " + sdf.format(currentDateTime));
		return userDAO.existUser(u);
	}
}
